package cn.edu.qzuie.artist.module.td.controller.app.student;

import cn.edu.qzuie.artist.framework.common.pojo.CommonResult;

import cn.edu.qzuie.artist.module.td.controller.app.student.vo.AppStudentAuthLoginRepVo;
import cn.edu.qzuie.artist.module.td.controller.app.student.vo.AppStudentAuthLoginRespVo;
import cn.edu.qzuie.artist.module.td.service.student.StudentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static cn.edu.qzuie.artist.framework.common.pojo.CommonResult.success;

/**
 * AppStudentController
 * 学生端 APP--controller
 * @author life.
 * @date 2025/3/31
 */
@Tag(name = "学生端 APP - TD学生")
@RestController
@RequestMapping("/td/appStudent")
@Validated
public class AppStudentController {
    @Resource
    private StudentService studentService;

    /**
     * 学生登陆--APP
     * @param reqVO
     * @return
     */
    @PostMapping("/login")
    @Operation(summary = "学生登录")
    public CommonResult<AppStudentAuthLoginRepVo> login(@Valid @RequestBody AppStudentAuthLoginRespVo reqVO) {
        AppStudentAuthLoginRepVo login = studentService.login(reqVO);
        return success(login);
    }

    /**
     * 学生令牌刷新
     * @param refreshToken
     * @return
     */
    @PostMapping("/refresh-token")
    @Operation(summary = "刷新令牌")
    @Parameter(name = "refreshToken", description = "刷新令牌", required = true)
    @PermitAll
    public CommonResult<AppStudentAuthLoginRepVo> refreshToken(@RequestParam("refreshToken") String refreshToken) {
        return success(studentService.refreshToken(refreshToken));
    }
}